package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsRegion;
import com.qf.service.DtsRegionService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wanghaotian
 * time:2022/12/21,0021 14:34
 * description:
 */

@RestController
@CrossOrigin("*")
@RequestMapping("/admin/region")
public class RegionController {

    @Autowired
    private DtsRegionService regionService;

    @GetMapping("/list")
    public Object list(
            @RequestParam(value = "page",required = false,defaultValue = "1") Integer page,
            @RequestParam(value = "limit",required = false,defaultValue = "20") Integer limit,
            String name,Integer code,String sort,String order
    ){
        IPage<DtsRegion> iPage = regionService.findPage(page,limit,name,code,sort,order);
        Map<String,Object> data = new HashMap<>();
        data.put("total", iPage.getTotal());
        data.put("items", iPage.getRecords());
        return ResponseUtil.ok(data);
    }
}
